import java.util.ArrayList;
import java.util.List;

/**This class reprent a potential rule of the mining algorithm
 * */
public class Rule implements Comparable {
	
	/**The left side of the rule
	 * */
	List<String> left=new ArrayList<String>();
	/**The right side of the rule
	 * */
	List<String> right=new ArrayList<String>();
	
	/**The support of this rule
	 * */
	private double sup;
	/** the confidence of this rule
	 * */
	private double conf;
	
	public Rule(List<String> left, List<String> right, double conf, double sup){
		this.left=left;
		this.right=right;
		this.sup=sup;
		this.conf=conf;
		
	}
	
	public double getConf(){
		return conf;
	}
	public int compareTo(Object o) {
		Rule r2=(Rule) o;
		if(this.equals(r2)){
		   return 0;
		}else if(this.getConf()>r2.getConf()){
			return -1;
		}else{
			return 1;
		}
	}
	public boolean equals(Object o){
		Rule r2=(Rule) o;
		if(this.conf==r2.getConf()){
			return true;
		}else{
			return false;
		}
	}
    public String toString(){
    	
    	return left+"=>"+right+"\t(Conf: "+conf*100+"%"+"Supp: "+sup*100+"%)"+"\n";
    }
}
